package com.th.atguigu.service;

import com.th.atguigu.dao.AccountMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.Map;

/**
 * @author ThreePure
 * @date 2022/3/11 9:07
 * @description: TODO
 * @since 1.8
 */

@Service
@Transactional
public class AccountService {
    /**注入dao*/
    @Autowired
    private AccountMapper accountMapper;

    public void accountMoney(){

        Map<String, Object> map = new HashMap<>();
        map.put("id", "1");
        map.put("money", 900);

        Map<String, Object> map2 = new HashMap<>();
        map2.put("id", "2");
        map2.put("money", 1100);

        /**转出资金*/
        accountMapper.reduceMoney(map);

        int x = 10/0;

        /**转入资金*/
        accountMapper.addMoney(map2);
    }
}
